﻿using System;
using System.Activities;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WFExtended.Twitter.Activities.Designers;

namespace WFExtended.Twitter.Activities
{
    /// <summary>
    /// Sends a new direct message to the specified user from the authenticating user.
    /// </summary>
    [ToolboxBitmapAttribute(typeof(EntryPoint), "Resources.DirectMessageToolbox.bmp")]
    [Designer(typeof(SendDirectMessageDesigner))]
    [Description("Sends a new direct message to the specified user from the authenticating user.")]
    public class SendDirectMessage : TwitterOperationInvoker<DirectMessage>
    {

        /// <summary>
        /// Initializes a new instance of the <see cref="SendDirectMessage"/> class.
        /// </summary>
        public SendDirectMessage()
            : base("AddDirectMessageWithUsername")
        {
            Username = new InArgument<string>();
            Text = new InArgument<string>();
        }


        /// <summary>
        /// The screen name of the user who should receive the direct message. 
        /// </summary>
        /// <value>
        /// The screen name of the user who should receive the direct message. 
        /// </value>
        [Browsable(true)]
        [Category("Parameters")]
        [Description("The screen name of the user who should receive the direct message.")]
        [RequiredArgument]
        public InArgument<string> Username { get; set; }

        /// <summary>
        ///  The text of your direct message.
        ///  <remarks>
        ///  Be sure to URL encode as necessary, and keep the message under 140 characters.
        /// </remarks>
        /// </summary>
        /// <value>
        /// The text of your direct message.
        /// </value>
        [Browsable(true)]
        [Category("Parameters")]
        [Description(" The ID of the direct message.")]
        [RequiredArgument]
        public InArgument<string> Text { get; set; }


        /// <summary>
        /// Caches the metadata.
        /// </summary>
        /// <param name="metadata">The metadata.</param>
        protected override void CacheMetadata(NativeActivityMetadata metadata)
        {
            RuntimeArgument usernameArgument = new RuntimeArgument("Username", typeof(string), ArgumentDirection.In, true);
            metadata.Bind(Username, usernameArgument);
            metadata.AddArgument(usernameArgument);

            RuntimeArgument textArgument = new RuntimeArgument("Text", typeof(string), ArgumentDirection.In, true);
            metadata.Bind(Text, textArgument);
            metadata.AddArgument(textArgument);

            base.CacheMetadata(metadata);
        }

        /// <summary>
        /// Executes the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        protected override void Execute(NativeActivityContext context)
        {
            Parameters.Clear();

            Parameters.Add("username", Username);
            Parameters.Add("text", Text);

            base.Execute(context);
        }


    }
}
